/*************************************************************************
	> File Name: hzoj_242.cpp
	> Author: 
	> Mail: 
	> Created Time: Wed 14 Aug 2024 12:04:00 PM CST
 ************************************************************************/

#include<iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define MAX_N 100000
vector<long long> a(MAX_N + 5, 0), b(MAX_N + 5, 0);

bool check(vector<long long>& a, int n, int M, int x) {
	for(int i = 1; i <= n; i++) b[i] = a[i] - x;
	for(int i = 1; i <= n; i++) b[i] += b[i -1]; //前缀和
	long long pre_min = 0;
	for(int i = M; i <= n; i++) {
		pre_min = min(pre_min, b[i - M]);
		if(b[i] - pre_min >= 0) return true;
	}
	return false;
}

int getMaxAverage(vector<long long>& a, int n, int M, int max_num) {
	int head = 0, tail = max_num, mid;
	while(head < tail) {
		mid = (head + tail + 1) / 2;
		if(check(a, n, M, mid)) head = mid;
		else tail = mid - 1; 
	}
	return head;
}

int main() {
	int n, m;
	long long max_num = 0;
	cin >> n >> m;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		a[i] *= 1000;
		max_num = max(a[i], max_num);
	}
	cout << getMaxAverage(a, n, m, max_num) << endl;
	return 0;
}
